//
//  SucceedToApplyViewController.m
//  Fangmm
//
//  Created by 阮琦 on 16/3/3.
//  Copyright © 2016年 com.fangmm. All rights reserved.
//

#import "SucceedToApplyViewController.h"

#import "User.h"

#import <TSMessages/TSMessageView.h>
#import <MobClick.h>

#import <SDWebImage/UIImageView+WebCache.h>
#import <SDWebImage/UIButton+WebCache.h>
#import "ACMacros.h"
#import "Constants.h"

#import "AppDrawer.h"


@interface SucceedToApplyViewController ()

@end

@implementation SucceedToApplyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configureViewTitle];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    self.navigationController.navigationBarHidden = true;
    [MobClick beginLogPageView:@"成功申请小组"];
}

- (void)viewWillDisappear:(BOOL)animated {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    self.navigationController.navigationBarHidden = false;
    [MobClick endLogPageView:@"成功申请小组页"];
}

- (void)viewDidAppear:(BOOL)animated {
    [self configureAlerts];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark - Configuring the view’s layout behavior
- (void)configureAlerts {
    [TSMessage showNotificationInViewController:self title:@"申请成功!" subtitle:@"请等待室长通过申请" type:TSMessageNotificationTypeSuccess duration:2.0 canBeDismissedByUser:true];
}

- (void)configureViewTitle {
    User *user = [User sharedUser];
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:user.avatar]];
    if ([user.gender isEqual:@"f"]) {
        [self.genderImage setImage:[UIImage imageNamed:@"boy_22_22"]];
    } else {
        [self.genderImage setImage:[UIImage imageNamed:@"girl_22_22"]];
    }
    [self.infoLabel setText:[NSString stringWithFormat:@"%d后 %@",user.ageGroup, user.constellation]];
    [self.proInfoLabel setText:[NSString stringWithFormat:@"%@ - %@",user.industry, user.profession]];
    if (user.certification) {
        [self.checkImage setImage:[UIImage imageNamed:@"check_ID-44-36"]];
        for (UILabel *label in self.checkLabel) {
            [label setTextColor:RGBACOLOR(255, 118, 108, 1)];
        }
    } else {
        [self.checkImage setImage:[UIImage imageNamed:@"check_ID_dim-44-36"]];
        for (UILabel *label in self.checkLabel) {
            [label setTextColor:RGBACOLOR(160, 160, 160, 1)];
        }
    }
    if (user.enterpriseAuth) {
        [self.companyAuthImages setImage:[UIImage imageNamed:@"check_company"]];
        for (UILabel *label in self.companyAuthLabels) {
            [label setTextColor:RGBACOLOR(255, 118, 108, 1)];
        }
    } else {
        [self.companyAuthImages setImage:[UIImage imageNamed:@"check_company_dim"]];
        for (UILabel *label in self.companyAuthLabels) {
            [label setTextColor:RGBACOLOR(160, 160, 160, 1)];
        }
    }
    for (int i = 0; i < user.tags.count; i++) {
        if (user.tags.count <= self.tagsLabels.count) {
            UILabel *label = self.tagsLabels[i];
            [label setText:user.tags[i]];
        }
    }
    
}

- (IBAction)clickToMainIndex:(UIButton *)sender {
    [[AppDrawer sharedDrawer].centerViewController dismissViewControllerAnimated:true completion:^{
    }];
}

- (IBAction)clickToBack:(UIButton *)sender {
    [[AppDrawer sharedDrawer].centerViewController dismissViewControllerAnimated:true completion:^{
    }];
}

@end
